package com.woniu.supermarket.exception;

import com.woniu.supermarket.result.ResultResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(IllegalArgumentException.class)
    @ResponseBody
    public ResultResponse<Void> ParamExceptionHandler(){

        return new ResultResponse<>(400,"参数异常");
    }

    @ExceptionHandler(NullPointerException.class)
    @ResponseBody
    public ResultResponse<Void> NUllPointExceptionHandler(){
        return new ResultResponse<>(500,"空指针");
    }

}
